
#include "Message.h"

Message::Message() : type(0), data(0){}

Message::Message(unsigned int t, unsigned long data)
{
	type = t;
	this->data = data;
}

Message::Message(char* buffer, int size){
	memcpy(&type, buffer, sizeof(unsigned int));
	memcpy(&data, &buffer[sizeof(unsigned int)], sizeof(unsigned long));
}

Message::~Message() {}

int Message::size(){
	return (sizeof(unsigned int) + sizeof(unsigned long));
}

char* Message::serialize(){
	char* buffer = new char[sizeof(type) + sizeof(data)];
	memcpy(buffer, &type, sizeof(type));
	memcpy(&buffer[sizeof(type)], &data, sizeof(data));
	return buffer;
}
